package YuanFuDao2;

/**
 * 最长不连续序列
 * 例如：Array[6] = {1，5，2，4，3，8}
 * 其最长递增子序列就1，2，4,8或1，2，3，8，最长长度为4
 */
public class Main4 {
    public static void main(String[] args) {
        int[] nums = {1,5,2,4,3,8};
        System.out.println(help(nums));
    }

    public static int help(int[] nums){
        if(nums == null || nums.length == 0) return 0;
        int[] dp = new int[nums.length];
        dp[0] = 1;
        int res = 1;
        for (int i = 1; i < nums.length; i++) {
            dp[i] = 1;
            for (int j = 0; j < i; j++) {
                if(nums[i] > nums[j]){
                    dp[i] = Math.max(dp[i],dp[j]+1);
                }
            }
            res = Math.max(res,dp[i]);
        }
        return res;
    }

}
